Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[amplipi] Initial contribution of AmpliPi binding #10983

Merged
merged 12 commits into from
Aug 1, 2021

Conversation

kaikreuzer
Copy link
Member

@kaikreuzer kaikreuzer commented Jul 12, 2021

This binding supports the AmpliPi home audio system - see https://www.micro-nova.com/amplipi.

Signed-off-by: Kai Kreuzer [email protected]

@kaikreuzer kaikreuzer added the new binding If someone has started to work on a binding. For a new binding PR. label Jul 12, 2021
@sumnerboy12
Copy link
Contributor

Nice, following with interest! Once I get mine I might be able to help out also.

@Skinah Skinah changed the title Initial contribution of AmpliPi binding [amplipi] Initial contribution of AmpliPi binding Jul 13, 2021
@kaikreuzer kaikreuzer added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Jul 15, 2021
@kaikreuzer
Copy link
Member Author

FTR, some discussion on the right modelling is taking place at micro-nova/AmpliPi#54.

@kaikreuzer kaikreuzer added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Jul 27, 2021
@kaikreuzer kaikreuzer added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Jul 28, 2021
@kaikreuzer kaikreuzer marked this pull request as ready for review July 28, 2021 08:36
@kaikreuzer kaikreuzer requested a review from a team as a code owner July 28, 2021 08:36
@kaikreuzer
Copy link
Member Author

@openhab/add-ons-maintainers This is now ready for review. The implementation contains the main features that make sense to have. Future PRs will add further functionality.

Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you add the generated files by intention?

There are some checkstyle warnings left.

super(thing);
this.httpClient = httpClient;
this.gson = new Gson();
id = Integer.valueOf(thing.getConfiguration().get(AmpliPiBindingConstants.CFG_PARAM_ID).toString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be set in initialize() to be updated on configuration updates?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I have now removed the field completely and use a method instead. This way, we can be sure that it's always the latest value that is used.

updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"AmpliPi request failed: " + e.getMessage());
} catch (ExecutionException e) {
logger.error("HTTP request to AmpliPi failed: {}.", e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem resonable to log to error when the network fails.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's a network issue, we run into the TimeoutException which is caught above.
I am not exactly sure in which situations an ExecutionException exactly occurs - that's why I rather considered it a bug situation as long as it isn't better handled. Do you happen to know when we can expect the ExecutionException from the httpClient?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting question. I always assumed that a ExecutionException can be caused by a network failure. I did a quick search and couldn't find any official documentation, but I found some stack traces showing this (in an OH context):

Caused by: java.util.concurrent.ExecutionException: java.net.ConnectException: Connection refused
at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118)
...

I would handle this as a network failure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure. A "Connection refused" means that the network is available, but that the contacted device did not accept the request at all - meaning that the request was invalid (e.g. by using a wrong port), so it might be due to a bug in the code.
But it's ok for me to treat it like a network issue - users will complain, if their things go OFFLINE for an ununderstood reason anyhow. I've changed the code accordingly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or the host is available, but the service is down. I think you can't clearly differentiate between temprorary or fatal errors here.

Signed-off-by: Kai Kreuzer <[email protected]>
@kaikreuzer
Copy link
Member Author

Did you add the generated files by intention?

Yes, absolutely. The code has actually be manually adapted after generation and the generator is configured to not overwrite existing files. I thought I leave the maven plugin in the pom, so that it is easier in future to generate additional model classes when the Swagger file is extended by new features.

@kaikreuzer kaikreuzer added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Jul 31, 2021
Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fwolter fwolter merged commit f25cc8d into openhab:main Aug 1, 2021
@fwolter fwolter added this to the 3.2 milestone Aug 1, 2021
@kaikreuzer kaikreuzer deleted the amplipi branch August 1, 2021 10:32
@fwolter
Copy link
Member

fwolter commented Aug 1, 2021

The build leaves an untracked file: bundles/org.openhab.binding.amplipi/.openapi-generator/amplipi-api.yml.sha256 Should we add it to gitignore?

@kaikreuzer
Copy link
Member Author

Yes. I have created #11081 for it.

frederictobiasc pushed a commit to frederictobiasc/openhab-addons that referenced this pull request Oct 26, 2021
* Initial contribution of AmpliPi binding

Signed-off-by: Kai Kreuzer <[email protected]>

* change http client from cxf jax-rs to Jetty

Signed-off-by: Kai Kreuzer <[email protected]>

* applied spotless

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove Jackson dependency

Signed-off-by: Kai Kreuzer <[email protected]>

* Add support for input handling

Signed-off-by: Kai Kreuzer <[email protected]>

* Clean up, improvements and documentation

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove unused password from configuration class

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove example properties file

Signed-off-by: Kai Kreuzer <[email protected]>

* revert change in .gitignore

Signed-off-by: Kai Kreuzer <[email protected]>

* Update README

Signed-off-by: Kai Kreuzer <[email protected]>

* Address review feedback

Signed-off-by: Kai Kreuzer <[email protected]>

* Handle ExecutionException as network error

Signed-off-by: Kai Kreuzer <[email protected]>
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this pull request Nov 7, 2021
* Initial contribution of AmpliPi binding

Signed-off-by: Kai Kreuzer <[email protected]>

* change http client from cxf jax-rs to Jetty

Signed-off-by: Kai Kreuzer <[email protected]>

* applied spotless

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove Jackson dependency

Signed-off-by: Kai Kreuzer <[email protected]>

* Add support for input handling

Signed-off-by: Kai Kreuzer <[email protected]>

* Clean up, improvements and documentation

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove unused password from configuration class

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove example properties file

Signed-off-by: Kai Kreuzer <[email protected]>

* revert change in .gitignore

Signed-off-by: Kai Kreuzer <[email protected]>

* Update README

Signed-off-by: Kai Kreuzer <[email protected]>

* Address review feedback

Signed-off-by: Kai Kreuzer <[email protected]>

* Handle ExecutionException as network error

Signed-off-by: Kai Kreuzer <[email protected]>
dschoepel pushed a commit to dschoepel/openhab-addons that referenced this pull request Nov 9, 2021
* Initial contribution of AmpliPi binding

Signed-off-by: Kai Kreuzer <[email protected]>

* change http client from cxf jax-rs to Jetty

Signed-off-by: Kai Kreuzer <[email protected]>

* applied spotless

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove Jackson dependency

Signed-off-by: Kai Kreuzer <[email protected]>

* Add support for input handling

Signed-off-by: Kai Kreuzer <[email protected]>

* Clean up, improvements and documentation

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove unused password from configuration class

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove example properties file

Signed-off-by: Kai Kreuzer <[email protected]>

* revert change in .gitignore

Signed-off-by: Kai Kreuzer <[email protected]>

* Update README

Signed-off-by: Kai Kreuzer <[email protected]>

* Address review feedback

Signed-off-by: Kai Kreuzer <[email protected]>

* Handle ExecutionException as network error

Signed-off-by: Kai Kreuzer <[email protected]>
Signed-off-by: Dave J Schoepel <[email protected]>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
* Initial contribution of AmpliPi binding

Signed-off-by: Kai Kreuzer <[email protected]>

* change http client from cxf jax-rs to Jetty

Signed-off-by: Kai Kreuzer <[email protected]>

* applied spotless

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove Jackson dependency

Signed-off-by: Kai Kreuzer <[email protected]>

* Add support for input handling

Signed-off-by: Kai Kreuzer <[email protected]>

* Clean up, improvements and documentation

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove unused password from configuration class

Signed-off-by: Kai Kreuzer <[email protected]>

* Remove example properties file

Signed-off-by: Kai Kreuzer <[email protected]>

* revert change in .gitignore

Signed-off-by: Kai Kreuzer <[email protected]>

* Update README

Signed-off-by: Kai Kreuzer <[email protected]>

* Address review feedback

Signed-off-by: Kai Kreuzer <[email protected]>

* Handle ExecutionException as network error

Signed-off-by: Kai Kreuzer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new binding If someone has started to work on a binding. For a new binding PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants